home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / initscripts.preinst < prev    next >
Text File  |  2009-10-19  |  4KB  |  120 lines

  1. #! /bin/sh
  2. #
  3. # initscripts preinst
  4. #
  5.  
  6. set -e
  7.  
  8. # Remove a no-longer used conffile
  9. #
  10. # $1: conffile
  11. #
  12. # If the argument was not listed as a conffile, silently do nothing.
  13. # Adapted from code obtained from http://wiki.debian.org/DpkgConffileHandling
  14. eliminate_conffile() {
  15.     PKGNAME="initscripts"
  16.     CONFFILE="$1"
  17.  
  18.     if [ -e "$CONFFILE" ]; then
  19.         CURRENT_MD5SUM="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  20.         FACTORY_MD5SUM="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
  21.         if [ "$CURRENT_MD5SUM" != "$FACTORY_MD5SUM" ]; then
  22.             echo "Obsolete conffile $CONFFILE has been modified by you."
  23.             echo "Saving as $CONFFILE.dpkg-old ..."
  24.             mv -f "$CONFFILE" "$CONFFILE".dpkg-old
  25.         else
  26.             echo "Removing unmodified and obsolete conffile $CONFFILE ..."
  27.             rm -f "$CONFFILE"
  28.         fi
  29.     fi
  30. }
  31.  
  32. # Compares a file to the "factory md5sum", and if it matches, removes it.
  33. # This is useful for when converting from to a conffile *and* changing
  34. # its contents at the same time.
  35. convert_to_conffile() {
  36.        CONFFILE="$1"
  37.        FACTORY_MD5SUM="$2"
  38.  
  39.        if [ -e "$CONFFILE" ]; then
  40.            CURRENT_MD5SUM="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  41.            if [ "$CURRENT_MD5SUM" = "$FACTORY_MD5SUM" ]; then
  42.                rm -f "$CONFFILE"
  43.            fi
  44.        fi
  45. }
  46.  
  47.  
  48. case "$1" in
  49.   install|upgrade)
  50.     #
  51.     # /etc/init.d/stop-bootlogd used to be a symlink to bootlogd;
  52.     # now it is a separate script.  We need to remove the symlink here,
  53.     # before dpkg installs the /etc/init.d/stop-bootlogd file.
  54.     #
  55.     [ -L /etc/init.d/stop-bootlogd ] && rm -f /etc/init.d/stop-bootlogd
  56.     #
  57.     # Remove obsolete conffiles
  58.     #
  59.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-10" ; then
  60.         eliminate_conffile "/etc/init.d/bootclean.sh"
  61.     fi
  62.     #
  63.     # The /etc/init.d/bootclean script fragment was moved to
  64.     # /lib/init/ in version 2.86.ds1-39
  65.     #
  66.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-54" ; then
  67.         eliminate_conffile "/etc/init.d/bootclean"
  68.     fi
  69.     #
  70.     # The /etc/init.d/waitnfs.sh script was replaced by mountnfs.sh
  71.     #
  72.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-56ubuntu1" ; then
  73.         eliminate_conffile "/etc/init.d/waitnfs.sh"
  74.     fi
  75.     #
  76.     # The /etc/init.d/bootlogs.sh script was replaced by bootlogs
  77.     #
  78.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.87dsf-4ubuntu1" ; then
  79.         eliminate_conffile "/etc/init.d/bootlogs.sh"
  80.     fi
  81.     #
  82.     # The /etc/init.d/rc.local was made a conffile in 2.86.ds1-18,
  83.     # which for Ubuntu translates into "on upgrades to Intrepid and
  84.     # onwards". The only valid upgrade path to Intrepid is from Hardy,
  85.     # so we just check against the md5sum from there.
  86.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-18" ; then
  87.         convert_to_conffile "/etc/init.d/rc.local" e3756487011471f7753d5d94ce4b6af4
  88.     fi
  89.     #
  90.     # Removed as we switched to Upstart
  91.     #
  92.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.87dsf-4ubuntu6"; then
  93.         eliminate_conffile "/etc/network/if-up.d/mountnfs"
  94.         eliminate_conffile "/etc/init.d/bootlogs"
  95.         eliminate_conffile "/etc/init.d/checkfs.sh"
  96.         eliminate_conffile "/etc/init.d/checkroot.sh"
  97.         eliminate_conffile "/etc/init.d/mountkernfs.sh"
  98.         eliminate_conffile "/etc/init.d/hostname.sh"
  99.         eliminate_conffile "/etc/init.d/bootmisc.sh"
  100.         eliminate_conffile "/etc/init.d/mountall.sh"
  101.         eliminate_conffile "/etc/init.d/mountdevsubfs.sh"
  102.         eliminate_conffile "/etc/init.d/rmnologin"
  103.         eliminate_conffile "/etc/init.d/mtab.sh"
  104.         eliminate_conffile "/etc/init.d/mountoverflowtmp"
  105.         eliminate_conffile "/etc/init.d/mountnfs.sh"
  106.         eliminate_conffile "/etc/init.d/mountnfs-bootclean.sh"
  107.         eliminate_conffile "/etc/init.d/mountall-bootclean.sh"
  108.     fi
  109.     #
  110.     # Move conflicting log _file_ if present
  111.     #
  112.     [ -f /var/log/fsck ] && mv -f /var/log/fsck /var/log/fsck.dpkg-old
  113.     ;;
  114.   abort-upgrade)
  115.     exit 0
  116.     ;;
  117. esac
  118.  
  119. :
  120.